        
        var roll = autoAppearing = disorderAnimate = null;
        var mouseX,mouseY,targetTop;
        
        $(document).ready(function(){
            mouseX = event.clientX || 0;
            mouseY = event.clientY || 0;
            
            var nums = [];
            for(var n = 0;n < $('.examples .num').length;n++){
                $('.examples .num')[n].ind = n;
                nums.push(Number($('.examples .num')[n].innerText));
            } 
            
            $('.examples .num').text('1');
            function makeInterval(el){
                var index = el.ind;
                var addVal = 1;
                el.timeOut = function(){
                    if(nums[index] > 100){
                        addVal = Math.ceil(nums[index] / 100);
                    }
                    setTimeout(function(){
                        if(addVal <= nums[index] - el.innerText){
                            //el.time = parseInt(600 / (nums[index] - el.innerText));
                            setTimeout(function(){
                                el.innerText = String(Number(el.innerText) + addVal);
                                el.timeOut();
                            },10);
                        }else{
                            el.innerText = String(nums[index]);
                        }
                    },10);
                }
                el.timeOut();
            }
            roll = setInterval(function(){
                if(beginningDelay != null){
                    if(beginningDelay <= animateDelayCount) return false;
                }
                var ele_top = $('.case .roll')[0].offsetTop;
                var ele_h = 0;
                var window_h = window.innerHeight;
                var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                if((/*ele_top > window_h && */
                    //
                    ele_top < window_h + scrollTop)
                    &&
                    (ele_h + ele_top >scrollTop)
                     ||
                     (ele_top < window_h && scrollTop < ele_top)){
                         for(var s = 0;s < $('.examples .num').length;s++){
                             makeInterval($('.examples .num')[s]);
                         }
                         clearInterval(roll);
                     }
            },10);

            
            
            $('body').mousemove(function(event){
                mouseX = event.clientX;
                mouseY = event.clientY;
                
            })
           
            
            
            var autoAnimate = [];
            for(var a = 0;a < $('.autoAnimate').length;a++){
                $('.autoAnimate')[a].appears = false;
                autoAnimate.push($('.autoAnimate')[a]);
            }   
            
            autoAppearing = setInterval(function(){
                if(!autoAnimate.length){
                    clearInterval(autoAnimate);
                    autoAnimate = null;
                }
                if(beginningDelay != null){
                    if(beginningDelay <= animateDelayCount) return false;
                }
                var fixed = $('.navSide').css('height') == '50px'?true:false;
                for(var n = 0;n < autoAnimate.length;n++){
                    //var ele_top = autoAnimate[n].offsetTop;
                    var ele_h = autoAnimate[n].offsetHeight;
                    var window_h = window.innerHeight;
                    //var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                    var window_top = autoAnimate[n].getBoundingClientRect().top;
                    fixed && (ele_h -= 50);
                    autoAnimate[n].className.indexOf('disorder') > 0 && (window_h -= 160);
                    if(
                    //ele_top + 160 < window_h + scrollTop
                    window_top <= window_h
                    &&
                    window_top > - ele_h
                    //ele_h + ele_top > scrollTop
                     ){
                         if(autoAnimate[n].className.indexOf('inview') <= 0){
                            $('.autoAnimate:eq(' + n + ')').addClass('inview');
                         }
                         autoAnimate[n].appears = true;
                    }else{
                        if(autoAnimate[n].className.indexOf('inview') >= 0){
                            $('.autoAnimate:eq(' + n + ')').removeClass('inview');
                         }
                        autoAnimate[n].appears = false;
                    } 
                }
            },10);
        })

        